import random
from sensor.sensor import Sensor
from sensor.frame import Frame
from datetime import datetime
import time

class FakeSensor(Sensor):
    def __init__(self, interval: float):
        self.interval = interval

    def Open(self):
        pass

    def Read(self) -> Frame:
        time.sleep(self.interval)
        frame = Frame()
        frame.time = datetime.now()
        frame.illuminance = random.uniform(0, 1000)
        frame.atmospher = random.uniform(0, 100)
        frame.humidity = random.uniform(30, 50)
        frame.temperature = random.uniform(20, 30)
        frame.voltage = random.uniform(0, 5)
        frame.current = random.uniform(0, 1)
        return frame

    def Close(self):
        pass
